Momentum-based gradient descent from scratch